<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <!-- MOTW-DISABLED saved from url=(0014)about:internet -->
    <title>Create a counter in Table.onCreate</title>
    <link rel="StyleSheet" href="css/ScriptingWithJavaScript.css" type="text/css" media="all" />
    <link rel="StyleSheet" href="css/webworks.css" type="text/css" media="all" />
    <link rel="StyleSheet" href="webworks.css" type="text/css" media="all" />
    <script type="text/javascript" language="JavaScript1.2">
      <!--
        var  WebWorksRootPath = "";
      // -->
    </script>
  </head>
  <body>
    <div style="text-align: left;">
      <table cellspacing="0" summary="">
        <tr>
          <td>
            <a href="ScriptingWithJavaScript.22.07.html"><img src="images/prev.gif" alt="Previous" border="0" /></a>
          </td>
          <td>
            <a href="ScriptingWithJavaScript.22.09.html"><img src="images/next.gif" alt="Next" border="0" /></a>
          </td>
        </tr>
      </table>
    </div>
    <hr align="left" />
    <blockquote>
      <h3 class="N_TutorialTask">Task 2:&nbsp;&nbsp;<a name="151750">Create a counter in Table.onCreate</a></h3>
      <p class="b_Body"><a name="151752">To count the number of customers whose names contain the string Mini, first declare a global counter and set its value to zero. The Table.onCreate method is the most appropriate place to perform this task because Table.onCreate executes before retrieving any rows. In the next task, you conditionally increment this counter in the Row.onCreate(&nbsp;) method.</a></p>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">1&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="151753">In Layout, select the table by placing the cursor near the bottom left corner of the table. The table icon appears, as shown in </a><a href="#152867" title="Create a counter in Table.onCreate">Figure&nbsp;22-5</a>.</div>
            </td>
          </tr>
        </table>
      </div>
      <p class="i2_Image2"><a name="151765"><img class="Default" src="images/tutorial3Shot2.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 22-5 List icon in the layout editor" /></a></p>
      <div class="fc2_FigCall2Title">
        <b class="Bold">Figure&nbsp;22-5&nbsp;&nbsp;</b><a name="152867">List icon in the layout editor</a></div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">2&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="151770">Choose the Script tab. The script editor appears, as shown in </a><a href="#152869" title="Create a counter in Table.onCreate">Figure&nbsp;22-6</a>.</div>
            </td>
          </tr>
        </table>
      </div>
      <p class="i2_Image2"><a name="151778"><img class="Default" src="images/tutorial3Shot3.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 22-6 Script window" /></a></p>
      <div class="fc2_FigCall2Title">
        <b class="Bold">Figure&nbsp;22-6&nbsp;&nbsp;</b><a name="152869">Script window</a></div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">3&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="151780">Select onCreate from the list of available scripts.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">4&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="175998">Type the following line of code in the script editor for the onCreate method:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="cfi_CodeFirstIndent"><a name="151781">countOfMinis = 0;</a></div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">5&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="151786">To run the report and verify that the code did not create any errors, choose Preview.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">6&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="151789">Scroll to the bottom of the report, where JavaScript error messages appear. If there are no errors, the report appears as shown in </a><a href="#152871" title="Create a counter in Table.onCreate">Figure&nbsp;22-7</a>. </div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_i_Indent1"><a name="151793">If you see an error message, you may have typed the statement incorrectly. If so, go back to the script window, select the method you just modified, correct the error, and choose Preview again.</a></div>
      <p class="i2_Image2"><a name="151801"><img class="Default" src="images/tutorial3Shot4.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 22-7 Report preview" /></a></p>
      <div class="fc2_FigCall2Title">
        <b class="Bold">Figure&nbsp;22-7&nbsp;&nbsp;</b><a name="152871">Report preview</a></div>
    </blockquote>
    <hr align="left" />
    <table align="right" summary="">
      <tr>
        <td class="WebWorks_Company_Name_Bottom">
          <a href="notices.html">(c) Copyright Actuate Corporation 2013</a>
        </td>
      </tr>
    </table>
  </body>
</html>